

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="/static/js/jquery-1.11.1.js"></script>
<script>
	$(function(){
		$("#s").click(function(){
			var template1=$("#template1").val();
			var template2=$("#template2").val();
            var selectedfun=$("#sid").val();
			$.ajax({
  	  			url:"http://localhost:8098/freemarker/updateAlarm",//要请求的服务器url
  	  			data:{template1:template1,template2:template2,selectedfun:selectedfun},//第一个name对应的是后端request.getParameter("name")的name、第二个name对应的是此js中的var name = $("#name").val();的name
  	  			async:true,//是否是异步请求
  	  			cache:false,//是否缓存结果
  	  			type:"POST",//请求方式
  	  			dataType:"text",//服务器返回什么类型数据 text xml javascript json(javascript对象)
  	  			success:function(result){//函数会在服务器执行成功后执行，result就是服务器返回结果  
  	  				$("#template3").html(result);			
  	  			},
  	  			error:function(jqXHR, textStatus, errorThrown) {
  	  	   	 		
  	  	    	}
			});
		});
		$("#s2").click(function(){
            var selectedfun=$("#sid").val();
			var str1 = '{\r\n"simplename":"ej",\r\n"yaoce":[ \r\n{"name":"internalvoltage1  ","comment":"内部电压1"},\r\n],\r\n"yaoxin":[ 		\r\n{"name":"devicefaultsignal","comment":"装置故障信号"},\r\n]\r\n}';
			var str3 = '{\r\n"structname":"txpds",\r\n"devicename":"TXPD",\r\n"LNname":"SPTR"\r\n}';
			var str33 = '${r'<#list 1..30 as i>'}\r\n${r'${demo.structname }'}[${r'${i}'}].IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}_CGAmp_t=IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}${r'${i}'}_CGAmp_t;\r\n${r'${demo.structname }'}[${r'${i}'}].IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}_CGAmp_mag_f=IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}${r'${i}'}_CGAmp_mag_f;\r\n${r'${demo.structname }'}[${r'${i}'}].IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}_MoDevConf_stVal=IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}${r'${i}'}_MoDevConf_stVal;\r\n${r'${demo.structname }'}[${r'${i}'}].IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}_SupDevRun_stVal=IEDMODEL_${r'${demo.devicename}'}MONT_${r'${demo.LNname}'}${r'${i}'}_SupDevRun_stVal;\r\n${r'</#list>'}';
			if(selectedfun == "自动生成61850模板"){
				$("#template1").html(str3);
				$("#template2").html(str33);
			}
			var str1 = '{\r\n"simplename": "ej",\r\n"yaoce": [\r\n  {"name": "internalvoltage1", "comment": "内部电压1"},\r\n  {"name": "internalvoltage2", "comment": "内部电压2"},\r\n  {"name": "internalvoltage3", "comment": "内部电压3"},\r\n  {"name": "internalvoltage4", "comment": "内部电压4"},\r\n  {"name": "internalvoltage5", "comment": "内部电压5"}\r\n],\r\n"yaoxin": [\r\n  {"name": "devicefaultsignal", "comment": "装置故障信号"},\r\n  {"name": "timingsignalstatus", "comment": "对时信号状态"},\r\n  {"name": "timeservicestatus", "comment": "对时服务状态"}\r\n]\r\n}';
			if(selectedfun == "自动生成创建数据库语句"){
				$("#template1").html(str1);
			}
		});
		$("#s1").click(function(){
			$("#template1").html("");
			$("#template2").html("");
		});
	});
	function select(){
		$("#title").html($("#sid").val());	
	}
</script>
</head>
<body>
<select  id="sid" onchange="select()">
   	<option>---请选择---</option>
   	<option>自动生成创建数据库语句</option>
	<option>自动生成comCenter</option>
   	<option>自动生成61850模板</option>
   	<option>自动生成模板4</option>
</select>
 <button id="s2">填充例子</button>
 <button id="s">生成</button>
<button id="s1">重置</button>
<h1  id="title"></h1>


<textarea id="template2" name="template2" rows="30" cols="200"></textarea>
<textarea id="template1" name="template1" rows="30" cols="80"></textarea>
<textarea id="template3" name="template3" rows="30" cols="200"></textarea>

<span id="re"></span>
</body>
</html>
